﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

public partial class admin_statistics_sGold : System.Web.UI.Page
{
    public string sell10 = "";
    public string sell30 = "";
    public string sell50 = "";

    public string topUp10 = "";
    public string topUp30 = "";
    public string topUp50 = "";

    public string countSell = "";
    public string countTopUp = "";

    public string SellNum = "";
    public string TopUpNum = "";

    public string time1 = "";
    public string time2 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.Execute("../inc/checkPurview.aspx");  // 此处用户权限验证
        Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_StarryNight_FlatCrystal_Glow_NoBorder;
        Chartlet1.Fill.ShiftStep = 8;
        Chartlet1.Crystal.Contraction = 0;
        Chartlet1.Shadow.Distance = 20;
        Chartlet1.Shadow.Alpha = 100;
        Chartlet1.XLabels.UnitText = "类型";
        Chartlet1.YLabels.UnitText = "次数";
        Chartlet1.Width = 600;
        Chartlet1.Height = 400;
        ArrayList aLabel = new ArrayList();
        aLabel.Add("金币10");
        aLabel.Add("金币30");
        aLabel.Add("金币50");

        ArrayList dataList1 = new ArrayList();
        dataList1.Add(0);
        dataList1.Add(0);
        dataList1.Add(0);

        ArrayList dataList2 = new ArrayList();
        dataList2.Add(0);
        dataList2.Add(0);
        dataList2.Add(0);

        ArrayList ColorGuider = new ArrayList();
        ColorGuider.Add("购买次数");
        ColorGuider.Add("充值次数");

        ArrayList[] dataL = { dataList1, dataList2 };
        Chartlet1.ChartTitle.Text = "金币购买充值次数统计\n\r";

        Chartlet1.InitializeData(dataL, aLabel, ColorGuider);
    }
    protected void btn_ok_Click(object sender, EventArgs e)
    {
        db_gold gold = new db_gold();
        time1 = tb_time_1.Text;
        time2 = tb_time_2.Text;
        DataSet ds = gold.statisticsGoldSell("10", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            sell10 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            sell10 = "0";
        }
        ds = gold.statisticsGoldSell("30", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            sell30 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            sell30 = "0";
        }
        ds = gold.statisticsGoldSell("50", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            sell50 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            sell50 = "0";
        }

        ds = gold.statisticsGoldTopUp("10", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            topUp10 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            topUp10 = "0";
        }
        ds = gold.statisticsGoldTopUp("30", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            topUp30 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            topUp30 = "0";
        }
        ds = gold.statisticsGoldTopUp("50", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            topUp50 = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            topUp50 = "0";
        }

        try
        {
            countSell = (Int32.Parse(sell10) + Int32.Parse(sell30) + Int32.Parse(sell50)).ToString();
            SellNum = (Int32.Parse(sell10)*10 + Int32.Parse(sell30)*30 + Int32.Parse(sell50)*50).ToString();
        }
        catch
        {
            countSell = "";
            SellNum = "";
        }

        try
        {
            countTopUp = (Int32.Parse(topUp10) + Int32.Parse(topUp30) + Int32.Parse(topUp50)).ToString();
            TopUpNum = (Int32.Parse(topUp10) * 10 + Int32.Parse(topUp30) * 30 + Int32.Parse(topUp50) * 50).ToString();
        }
        catch
        {
            countTopUp = "";
            TopUpNum = "";
        }

        ArrayList aLabel = new ArrayList();
        aLabel.Add("金币10");
        aLabel.Add("金币30");
        aLabel.Add("金币50");

        ArrayList dataList1 = new ArrayList();
        dataList1.Add(sell10);
        dataList1.Add(sell30);
        dataList1.Add(sell50);

        ArrayList dataList2 = new ArrayList();
        dataList2.Add(topUp10);
        dataList2.Add(topUp30);
        dataList2.Add(topUp50);

        ArrayList ColorGuider = new ArrayList();
        ColorGuider.Add("购买次数");
        ColorGuider.Add("充值次数");

        ArrayList[] dataL = { dataList1, dataList2 };

        Chartlet1.ChartTitle.Text = time1 + " ~ " + time2 + " 金币购买充值次数统计\n\r";
        Chartlet1.InitializeData(dataL, aLabel, ColorGuider);
    }
}